﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Controls;
using H2.NET.Business;
using H2.NET.Data.Common;

namespace H2.NET.Web.Pages
{
    public partial class PNVD : TaskPage
    {
        #region 属性 Public
        public string color
        {
            get
            {
                return VD_Category.SelectedValue == "1" && TaskAPI.IsBeginStep ? "Blue" : "Black";
            }
        }

        public string color2
        {
            get
            {
                return VD_Category.SelectedValue == "1" || !TaskAPI.IsBeginStep ? "Black" : "Blue";
            }
        }

        public string color3
        {
            get
            {
                return TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit ? "Blue" : "Black";
            }
        }

        public string Vendor_Type
        {
            get
            {
                return ViewState["Vendor_Type"] == null ? "" : (string)ViewState["Vendor_Type"];
            }
            set { ViewState["Vendor_Type"] = value; }
        }

        public string Action_Type
        {
            get
            {
                return ViewState["Action_Type"] == null ? "" : (string)ViewState["Action_Type"];
            }
            set { ViewState["Action_Type"] = value; }
        }

        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }
        #endregion

        #region 事件 Page_Load(页面加载)
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                INFO.Text = string.Format("<br/>表单正在被同事“{0}”抢占处理，拒绝提交！", RobUser);
                INFO.Visible = IsOverFlow;

                bool flg = (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) ? true : false;


                InitDropDownList();

                #region 发起步骤
                if (TaskAPI.IsInitiate)
                {
                    VD.Checked = true;
                    Vendor_Type = "NA";
                    Action_Type = "1";
                }
                #endregion

                #region 审批环节
                else
                {
                    #region 加载数据并显示
                    nvd_Vendor vendor = (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident).ListFirst<nvd_Vendor>();
                    if (vendor != null)
                    {
                        ApplicationNo.Text = vendor.ApplicationNo;
                        VD.Checked = vendor.VD_Checked == "1";
                        //VD_Company.SelectedValue            = vendor.VD_Company;
                        //VD_Vendor_Type.SelectedValue        = vendor.VD_Vendor_Type;
                        SetDropDownListValue(VD_Company, vendor.VD_Company);
                        SetDropDownListValue(DrpPriority, vendor.DrpPriority);
                        SetDropDownListValue(DMO_DrpPriority, vendor.DMO_DrpPriority);
                        SetDropDownListValue(VD_Vendor_Type, vendor.VD_Vendor_Type);
                        Vendor_Type = vendor.VD_Vendor_Type;
                        VD_YY.Checked = vendor.VD_YY == "1";
                        VD_Description_1.Text = vendor.VD_Description_1;
                        VD_Description_2.Text = vendor.VD_Description_2;
                        VD_Search_Term.Text = vendor.VD_Search_Term;
                        VD_Street.Text = vendor.VD_Street;
                        VD_Country.Text = vendor.VD_Country;
                        //VD_Region.SelectedValue             = vendor.VD_Region;
                        SetDropDownListValue(VD_Region, vendor.VD_Region);
                        VD_City.Text = vendor.VD_City;
                        VD_Street5.Text = vendor.VD_Street5;
                        VD_District.Text = vendor.VD_District;
                        VD_Street4.Text = vendor.VD_Street4;
                        VD_Postal_Code.Text = vendor.VD_Postal_Code;
                        if (TaskAPI.Step != "Finance")
                        {
                            SetDropDownListValue(VD_Schema_Group, vendor.VD_Schema_Group);
                            SetDropDownListValue(VD_Confirmation_Control, vendor.VD_Confirmation_Control);
                            SetDropDownListValue(VD_PI, vendor.VD_PI);
                        }
                        else
                        {
                            VD_Schema_Group.SelectedValue = vendor.VD_Schema_Group;
                            VD_Confirmation_Control.SelectedValue = vendor.VD_Confirmation_Control;
                            VD_PI.SelectedValue = vendor.VD_PI;
                        }
                        //VD_Language.SelectedValue           = vendor.VD_Language;
                        SetDropDownListValue(VD_Language, vendor.VD_Language);
                        VD_Contact_Person.Text = vendor.VD_Contact_Person;
                        VD_Telephone.Text = vendor.VD_Telephone;
                        VD_Ext_1.Text = vendor.VD_Ext_1;
                        VD_Fax_Number.Text = vendor.VD_Fax_Number;
                        VD_Ext_2.Text = vendor.VD_Ext_2;
                        VD_Email.Text = vendor.VD_Email;
                        VD_Bank_Country.Text = vendor.VD_Bank_Country;
                        VD_Bank_Name.Text = vendor.VD_Bank_Name;
                        VD_Bank_Account.Text = vendor.VD_Bank_Account;
                        //VD_Recon_Account.SelectedValue      = vendor.VD_Recon_Account;
                        SetDropDownListValue(VD_Recon_Account, vendor.VD_Recon_Account);
                        //VD_Cash_Mgmnt_Group.SelectedValue   = vendor.VD_Cash_Mgmnt_Group;
                        SetDropDownListValue(VD_Cash_Mgmnt_Group, vendor.VD_Cash_Mgmnt_Group);
                        //VD_Payt_Terms.SelectedValue         = vendor.VD_Payt_Terms;
                        SetDropDownListValue(VD_Payt_Terms, vendor.VD_Payt_Terms);
                        //if (flg)
                        //{
                        //    VD_Payt_Terms_SelectedIndexChanged(null, e);
                        //}
                        VD_Payment_Methods = setCheckList(vendor.VD_Payment_Methods, VD_Payment_Methods);
                        //VD_Acctg_Clerk.SelectedValue        = vendor.VD_Acctg_Clerk;
                        SetDropDownListValue(VD_Acctg_Clerk, vendor.VD_Acctg_Clerk);

                        VD_Order_Currency.Text = vendor.VD_Order_Currency;
                        VD_Payment_Terms.SelectedValue = vendor.VD_Payment_Terms;
                        //VD_Purchasing_Group.SelectedValue   = vendor.VD_Purchasing_Group;
                        SetDropDownListValue(VD_Purchasing_Group, vendor.VD_Purchasing_Group);
                        VD_GR_Based.Checked = vendor.VD_GR_Based == "1";
                        if (!(TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit))
                        {
                            VD_Pricing_Date_Control.Text = vendor.VD_Pricing_Date_Control;
                            VD_Acct_statement.Text = vendor.VD_Acct_statement;
                        }

                        //VD_Category.SelectedValue           = vendor.VD_Category;
                        SetDropDownListValue(VD_Category, vendor.VD_Category);
                        Action_Type = vendor.VD_Category; ;
                        VD_Area1.Checked = vendor.VD_Area == "1";
                        VD_Area2.Checked = vendor.VD_Area == "2";
                        VD_Area3.Checked = vendor.VD_Area == "3";
                        if (vendor.VD_Area == "3" & VD_Category.SelectedValue == "1")
                        {
                            SetForeColor(Color.Blue, VD_Telephone_L, VD_Fax_Number_L);
                        }
                        VD_Vendor_Master_Code.Text = vendor.VD_Vendor_Master_Code;
                        VD_Customer_sold_to_code.Text = vendor.VD_Customer_sold_to_code;
                        SA.Checked = vendor.SA_Checked == "1";
                        SA_Temp_Staff.Checked = vendor.SA_Temp_Staff == "1";
                        SA_Vendor_Master_Code.Text = vendor.SA_Vendor_Master_Code;
                        SA_Name.Text = vendor.SA_Name;
                        SA_Company.Text = vendor.SA_Company;
                        SA_Gender.SelectedValue = vendor.SA_Gender;
                        SA_Nationality.Text = vendor.SA_Nationality;
                        SA_ID_No.Text = vendor.SA_ID_No;
                        SA_Region.Text = vendor.SA_Region;
                        SA_City.Text = vendor.SA_City;
                        SA_District.Text = vendor.SA_District;
                        SA_Street.Text = vendor.SA_Street;
                        SA_Postal_Code.Text = vendor.SA_Postal_Code;
                        SA_Telephone.Text = vendor.SA_Telephone;
                        SA_Ext_3.Text = vendor.SA_Ext_3;
                        SA_Cell_Phone.Text = vendor.SA_Cell_Phone;
                        SA_Fax_Number.Text = vendor.SA_Fax_Number;
                        SA_Email.Text = vendor.SA_Email;
                        SA_Bank_Name.Text = vendor.SA_Bank_Name;
                        SA_Bank_Country.Text = vendor.SA_Bank_Country;
                        SA_SWIFT_BINN.Text = vendor.SA_SWIFT_BINN;
                        SA_Bank_Account.Text = vendor.SA_Bank_Account;

                        //SA_Sales_Person.SelectedValue       = vendor.SA_Sales_Person;
                        SetDropDownListValue(SA_Sales_Person, vendor.SA_Sales_Person);
                        //if (flg)
                        //{
                        //    SA_Sales_Person_SelectedIndexChanged(null, e);
                        //}
                        SA_Employment_Date.Text = vendor.SA_Employment_Date;
                        SA_Personnel_Area.Text = vendor.SA_Personnel_Area;
                        SetDropDownListValue(SA_EE_Group, vendor.SA_EE_Group);
                        //SA_EE_Group.SelectedValue           = vendor.SA_EE_Group;
                        //SA_Subarea.SelectedValue            = vendor.SA_Subarea;
                        SetDropDownListValue(SA_Subarea, vendor.SA_Subarea);
                        SA_EE_Su_Group.Text = vendor.SA_EE_Su_Group;

                        SA_Expense_User.Checked = vendor.SA_Expense_User == "1";
                        SA_Expense_Approver.Checked = vendor.SA_Expense_Approver == "1";

                        SetDropDownListValue(SA_State_Province, vendor.SA_State_Province);
                        SetDropDownListValue(SA_Legal_Entity, vendor.SA_Legal_Entity);
                        SetDropDownListValue(SA_Location, vendor.SA_Location);

                        SA_Employee_Grouping.Text = vendor.SA_Employee_Grouping;
                        SA_Employee_Group_Configuration.Text = vendor.SA_Employee_Group_Configuration;
                        SA_First_Name.Text = vendor.SA_First_Name;
                        SA_Last_Name.Text = vendor.SA_Last_Name;
                        SA_CTE_Login_Name.Text = vendor.SA_CTE_Login_Name;
                        SA_Account_Activation_Date.Text = vendor.SA_Account_Activation_Date;
                        SA_Account_Termination_Date.Text = vendor.SA_Account_Termination_Date;
                        SA_Employee_ID.Text = vendor.SA_Employee_ID;
                        SA_Email_Address.Text = vendor.SA_Email_Address;
                        SA_Country.Text = vendor.SA_Country;
                        SA_Ledger.Text = vendor.SA_Ledger;
                        SA_Cost_Object_Type.Text = vendor.SA_Cost_Object_Type;
                        SA_ERP_ID.Text = vendor.SA_ERP_ID;
                        SA_Currency.Text = vendor.SA_Currency;
                        SA_Cost_Object_Code.Text = vendor.SA_Cost_Object_Code;
                        SA_Approver_Linemanager.Text = vendor.SA_Approver_Linemanager;
                        SA_SWIFT_BIN.Text = vendor.SA_SWIFT_BIN;
                        SA_Bank_Country_Concur.Text = vendor.SA_Bank_Country_Concur;
                        SA_IBAN_Number.Text = vendor.SA_IBAN_Number;
                        SA_Local_Personnel_Number.Text = vendor.SA_Local_Personnel_Number;
                        SA_Pay_Roll_ID.Text = vendor.SA_Pay_Roll_ID;
                        SA_Region_Concur.Text = vendor.SA_Region_Concur;
                        SA_Country_Concur.Text = vendor.SA_Country_Concur;
                        SA_Travel_Rule.Text = vendor.SA_Travel_Rule;
                        SA_Business_Area.Text = vendor.SA_Business_Area;
                        SA_Business_Unit.Text = vendor.SA_Business_Unit;
                        SA_Sub_Business_Unit.Text = vendor.SA_Sub_Business_Unit;
                        SA_Default_Lanuage.Text = vendor.SA_Default_Lanuage;


                        SA2.Checked = vendor.SA2_Checked == "1";
                        SA2_Personnel_NO.Text = vendor.SA2_Personnel_NO;
                        SA2_From_Date.Text = vendor.SA2_From_Date;
                        //SA2_Personnel_Area.SelectedValue    = vendor.SA2_Personnel_Area;
                        SetDropDownListValue(SA2_Personnel_Area, vendor.SA2_Personnel_Area);
                        SetDropDownListValue(SA2_Company, vendor.SA2_Company);

                        //SA2_EE_Group.SelectedValue          = vendor.SA2_EE_Group;
                        SetDropDownListValue(SA2_EE_Group, vendor.SA2_EE_Group);

                        if (!(TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit))
                        {
                            SA2_EE_Sub_Group.Text = vendor.SA2_EE_Sub_Group;
                            SA2_Nationality.Text = vendor.SA2_Nationality;
                        }

                        //SA2_Subarea.SelectedValue           = vendor.SA2_Subarea;
                        SetDropDownListValue(SA2_Subarea, vendor.SA2_Subarea);
                        SA2_Last_Name.Text = vendor.SA2_Last_Name;
                        SA2_First_Name.Text = vendor.SA2_First_Name;
                        //SA2_Gender.SelectedValue            = vendor.SA2_Gender;
                        SetDropDownListValue(SA2_Gender, vendor.SA2_Gender);
                        SA2_ID_NO.Text = vendor.SA2_ID_NO;
                        SA2_Birth_Date.Text = vendor.SA2_Birth_Date;
                        if (!(TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit))
                        {
                            SA2_Sales_Organization.Text = vendor.SA2_Sales_Organization;
                        }
                        //SA2_Sales_Office.SelectedValue      = vendor.SA2_Sales_Office;
                        SetDropDownListValue(SA2_Sales_Office, vendor.SA2_Sales_Office);
                        SetDropDownListValue(SA2_Position, vendor.SA2_Position);
                        SA2_PerNo_Super.Text = vendor.SA2_PerNo_Super;

                        SA2_Street_And_HseNo.Text = vendor.SA2_Street_And_HseNo;
                        SA2_City.Text = vendor.SA2_City;
                        SA2_Mobile_Phone_Number.Text = vendor.SA2_Mobile_Phone_Number;
                        SA2_EMail_Address.Text = vendor.SA2_EMail_Address;
                        SAP_Code.Text = vendor.SAP_Code;
                        //TB添加
                        DMO_Arrpvoe_Creation_Number.Text = vendor.DMO_Arrpvoe_Creation_Number;
                        DMO_Arrpvoe_Creation_Time.Text = vendor.DMO_Arrpvoe_Creation_Time;
                        DMO_Maintain_Creation_Number.Text = vendor.DMO_Maintain_Creation_Number;
                        DMO_Maintain_Creation_Time.Text = vendor.DMO_Maintain_Creation_Time;
                        DMO_Check_Creation_Number.Text = vendor.DMO_Check_Creation_Number;
                        DMO_Check_Creation_Time.Text = vendor.DMO_Check_Creation_Time;
                        DMO_Arrpvoe_Revision_Number.Text = vendor.DMO_Arrpvoe_Revision_Number;
                        DMO_Arrpvoe_Revision_Time.Text = vendor.DMO_Arrpvoe_Revision_Time;
                        DMO_Maintain_Revision_Number.Text = vendor.DMO_Maintain_Revision_Number;
                        DMO_Maintain_Revision_Time.Text = vendor.DMO_Maintain_Revision_Time;
                        DMO_Check_Revision_Number.Text = vendor.DMO_Check_Revision_Number;
                        DMO_Check_Revision_Time.Text = vendor.DMO_Check_Revision_Time;
                        //DMO_SalesSAP_Code.Text              = vendor.DMO_SalesSAP_Code;
                        //DMO_Employee_Name.Text              = vendor.DMO_Employee_Name;
                        //DMO_ID_Card.Text                    = vendor.DMO_ID_Card;
                        DMO_SalesSAP_Code.Text = vendor.DMO_SalesSAP_Code;


                        SAP_Code.Text = vendor.SAP_Code;
                        DMO_Employee_Name.Text = SA_Name.Text;
                        DMO_ID_Card.Text = SA_ID_No.Text;
                        if (VD_Category.SelectedValue == "2" & VD.Checked)
                        {
                            SAP_Code.Text = VD_Vendor_Master_Code.Text;
                        }
                        if (VD_Category.SelectedValue == "2" & SA.Checked)
                        {
                            SAP_Code.Text = SA_Vendor_Master_Code.Text;
                        }
                        if (VD.Checked)
                        {
                            if (VD_Description_2.Text == "")
                            {
                                DMO_Employee_Name.Text = VD_Description_1.Text;
                            }
                            else if (VD_Description_1.Text == "")
                            {
                                DMO_Employee_Name.Text = VD_Description_2.Text;
                            }
                            else if (VD_Description_1.Text != "" & VD_Description_2.Text != "")
                            {
                                DMO_Employee_Name.Text = VD_Description_2.Text;
                            }
                        }
                        if (TaskAPI["R_Manager_Approve2"] != null)
                        {
                            object[] obj1 = (object[])(TaskAPI["R_Manager_Approve2"]);
                            for (int i = 0; i <= obj1.GetUpperBound(0); i++)
                            {
                                m_DR2 dr2 = (m_DR2.winId == obj1[i].ToString()).ListFirst<m_DR2>();
                                if (dr2 != null)
                                {
                                    VD_DR2.Text = dr2.Name;
                                }
                            }
                        }

                    }
                    #endregion

                    #region 审批项初始化
                    switch (TaskAPI.Step)
                    {
                        case "DMO Approve":
                        case "DMO Maintain":
                        case "DMO Check":
                        case "Finance":
                        case "LAM":
                            Assessment1.Option.Add(new t_AssessmentOption("Finish", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;
                        case "Manager Approve":
                        case "Accounting Manager":
                            Assessment1.Option.Add(new t_AssessmentOption("Approve", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;
                    }
                    #endregion
                }
                #endregion

                #region 设置控件禁启用
                //bool flg = (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) ? true : false;

                SetEnable(flg, VD_DR2, VD, SA, SA2, DrpPriority, VD_YY, SA2_Sales_Office, SA2_Position, VD_Company, VD_Description_1, VD_Description_2, VD_GR_Based, VD_Search_Term, VD_Street, VD_Country, VD_Region, VD_City, VD_Street5, VD_District, VD_Street4, VD_Postal_Code, VD_Language, VD_Contact_Person, VD_Telephone, VD_Ext_1, VD_Fax_Number, VD_Ext_2, VD_Schema_Group, VD_PI, VD_Confirmation_Control, VD_Email, VD_Bank_Country, VD_Bank_Name, VD_Bank_Account, VD_Recon_Account, VD_Cash_Mgmnt_Group, VD_Payt_Terms, VD_Payment_Methods, VD_Acctg_Clerk, VD_Payment_Terms, VD_Order_Currency, VD_Purchasing_Group, VD_Category, VD_Area1, VD_Area2, VD_Area3, VD_Vendor_Master_Code, VD_Customer_sold_to_code, SA_Vendor_Master_Code, SA_Name, SA_Company, SA_Gender, SA_Nationality, SA_ID_No, SA_Region, SA_City, SA_District, SA_Street, SA_Postal_Code, SA_Telephone, SA_Ext_3, SA_Cell_Phone, SA_Fax_Number, SA_Email, SA_Bank_Name, SA_Bank_Country, SA_SWIFT_BINN, SA_Bank_Account, SA_Sales_Person, SA_Employment_Date, SA_Personnel_Area, SA_EE_Group, SA2_Personnel_NO, SA2_From_Date, SA2_Personnel_Area, SA2_Company, SA2_EE_Group, SA2_Subarea, SA2_Last_Name, SA2_First_Name, SA2_Gender, SA2_ID_NO, SA2_Birth_Date, SA2_Street_And_HseNo, SA2_City, SA2_Mobile_Phone_Number, SA2_EMail_Address, SA2_PerNo_Super, SA_Temp_Staff, SAP_Code, SA_Subarea, SA_Expense_Approver, SA_First_Name, SA_Last_Name, SA_CTE_Login_Name, SA_Account_Activation_Date, SA_Account_Termination_Date, SA_Employee_ID, SA_State_Province, SA_Legal_Entity, SA_Cost_Object_Code, SA_Approver_Linemanager, SA_SWIFT_BIN, SA_IBAN_Number, SA_Location);
                SetEnable(flg, DMO_Arrpvoe_Creation_Number, DMO_Arrpvoe_Creation_Time, DMO_Maintain_Creation_Number, DMO_Maintain_Creation_Time, DMO_Check_Creation_Number, DMO_Check_Creation_Time, DMO_Arrpvoe_Revision_Number, DMO_Arrpvoe_Revision_Time, DMO_Maintain_Revision_Number, DMO_Maintain_Revision_Time, DMO_Check_Revision_Number, DMO_Check_Revision_Time);
                SetEnable(TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve", SAP_Code, DMO_SalesSAP_Code);
                SetEnable(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", DMO_DrpPriority);
                SetVisible(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", P_DMO);

                SetEnable(false, DMO_Employee_Name, DMO_ID_Card);
                SetEnable(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", DMO_Arrpvoe_Creation_Number, DMO_Arrpvoe_Creation_Time, DMO_Maintain_Creation_Number, DMO_Maintain_Creation_Time, DMO_Check_Creation_Number, DMO_Check_Creation_Time, DMO_Arrpvoe_Revision_Number, DMO_Arrpvoe_Revision_Time, DMO_Maintain_Revision_Number, DMO_Maintain_Revision_Time, DMO_Check_Revision_Number, DMO_Check_Revision_Time);
                SetForeColor(Color.Black, DMO_Arrpvoe_Creation_L, DMO_Maintain_Creation_L, DMO_Check_Creation_L, DMO_Arrpvoe_Revision_L, DMO_Maintain_Revision_L, DMO_Check_Revision_L);

                if (TaskAPI.Step == "DMO Approve" & VD_Category.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Arrpvoe_Creation_L);
                }
                if (TaskAPI.Step == "DMO Maintain" & VD_Category.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Maintain_Creation_L);
                }
                if (TaskAPI.Step == "DMO Check" & VD_Category.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Check_Creation_L);
                }
                if (TaskAPI.Step == "DMO Approve" & VD_Category.SelectedValue == "2")
                {
                    SetForeColor(Color.Blue, DMO_Arrpvoe_Revision_L);
                }
                if (TaskAPI.Step == "DMO Maintain" & VD_Category.SelectedValue == "2")
                {
                    SetForeColor(Color.Blue, DMO_Maintain_Revision_L);
                }
                if (TaskAPI.Step == "DMO Check" & VD_Category.SelectedValue == "2")
                {
                    SetForeColor(Color.Blue, DMO_Check_Revision_L);
                }
                //TB添加

                //SetEnable(TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Approve", DMO_Arrpvoe_Creation_Time, DMO_Maintain_Creation_Number, DMO_Check_Creation_Number, DMO_Arrpvoe_Revision_Number, DMO_Maintain_Revision_Number, DMO_Maintain_Revision_Time, DMO_Check_Revision_Number, DMO_Check_Revision_Time);
                bool flg1 = (TaskAPI.IsBeginStep) ? true : false;
                if (TaskAPI.Step == "DMO Maintain")
                {
                    SetForeColor(Color.Blue, SAP_Code_L);
                }
                SetVisible(SA.Checked | SA2.Checked, DMO_SalesSAP_Code, Sales_SAP_Code_L, DMO_ID_Card, ID_Card_L);
                IList<m_DR2> m_dr2 = (m_DR2.winId == UserAPI.UserName & m_DR2.status == 1).List<m_DR2>();

                if (m_dr2.Count > 0)
                {
                    SetVisible(flg1, this.P_DR2);
                }
                else
                {
                    SetVisible(false, this.P_DR2);
                }
                Assessment1.Enable = TaskAPI.IsAllowSubmit;
                SetVisible(TaskAPI.IsAllowSubmit, Send, Split);
                SetVisible(VD_Category.SelectedValue != "1", P1, P2, P3);

                //SetVisible(!SA_Temp_Staff.Checked, P_Concur);
                SetVisible(VD_Category.SelectedValue == "1", P5);
                //Attachment1.AllowDelete = TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit;
                //Attachment1.AllowUpload = TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit;
                InitTabs();
                #endregion

                #region 颜色加深
                if (!flg || !TaskAPI.IsAllowSubmit)
                {
                    foreach (Control cr in P_VD.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }
                    foreach (Control cr in P_VD.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                    foreach (Control cr in P_SA.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }
                    foreach (Control cr in P_SA.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                    foreach (Control cr in P_SA2.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }
                    foreach (Control cr in P_SA2.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }
                    //this.Actions.Enabled = true;
                }
                if (TaskAPI.Step == "Finance" && TaskAPI.IsAllowSubmit)
                {

                    SetEnable(true, VD_Schema_Group, VD_Confirmation_Control, VD_PI);
                }
                #endregion
            }
        }
        #endregion

        #region 事件 Send
        protected void Send_Click(object sender, EventArgs e)
        {
            try
            {
                #region 数据验证
                if ((TaskAPI.IsBeginStep || TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Check" || TaskAPI.Step == "DMO Approve") && TaskAPI.IsAllowSubmit) // 如果是退回的情况，不存在验证
                {
                    List<string> vald_s = new List<string>();
                    vald_s.AddRange(DataValidation());
                    if (vald_s.Count > 0)
                    {
                        Anthem.Manager.AddScriptForClientSideEval(string.Format("ShowMessage(\"{0}\", {1});", CombineMessage(vald_s), vald_s.Count));
                        return;
                    }
                }
                #endregion

                #region 引擎传值
                if (TaskAPI.IsBeginStep)
                {
                    if (TaskAPI.IsInitiate)
                    {
                        ApplicationNo.Text = Util.GenerateSequence(((object[])TaskAPI["PrefixNo"])[0].ToString() + "-" + System.DateTime.Now.ToString("yyMM"), "", 4);
                        TaskAPI.UserName = UserAPI.UserName;
                        TaskAPI["ApplicationNo"] = ApplicationNo.Text;
                        TaskAPI["ApplicatorName"] = UserAPI.UserFullName;
                        TaskAPI["Applicator"] = UserAPI.UserName;
                        TaskAPI["Time"] = System.DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                        //TaskAPI["ApplicatorEmail"] = UserAPI.Mail;
                        var applicatorEmail = GetEmailByWinId(new List<string> { "'" + UserAPI.UserName + "'" });
                        TaskAPI["ApplicatorEmail"] = applicatorEmail != null && applicatorEmail.Count > 0
                                                     ? applicatorEmail[0]
                                                     : string.Empty;
                        TaskAPI["Department"] = UserAPI.Department;
                        TaskAPI["ServerName"] = Util.AppSettings("ServerName");
                    }

                    TaskAPI.Summary = (VD_Category.SelectedItem.Text.Split(',').Length >= 2 ? VD_Category.SelectedItem.Text.Split(',')[1].Trim() : VD_Category.Text)
                                    + " / " + ApplicationNo.Text + (VD.Checked ? " / Vendor " : "") + (SA.Checked ? " / Employee " : "") + (SA2.Checked ? " / Sales Person " : "");

                    //TaskAPI["Vendor_Type"] = VD.Checked && VD_Vendor_Type.SelectedValue == "内部(Internal)" ? "Internal" : "";
                    TaskAPI["Actions"] = VD_Category.SelectedValue;
                    TaskAPI["Remark_by_Initiator"] = Assessment1.Assessment.Remark;
                    TaskAPI["DrpPriority"] = DrpPriority.SelectedItem.Text;

                    #region 从数据库取得流程步骤处理人
                    SortedList<string, string> rec_a = new SortedList<string, string>();

                    IList<mdc_Recipient> rec_s = (mdc_Recipient.process == TaskAPI.Process & (mdc_Recipient.distribute == VD_Category.SelectedValue | mdc_Recipient.distribute == "*") & mdc_Recipient.status == 1).List<mdc_Recipient>();
                    foreach (mdc_Recipient rec in rec_s)
                    {
                        if (!rec_a.ContainsKey(rec.Step))
                        {
                            rec_a.Add(rec.Step, rec.Recipient);
                            continue;
                        }

                        if (rec_a.Values[rec_a.IndexOfKey(rec.Step)].Contains(rec.Recipient))
                        {
                            continue;
                        }

                        rec_a[rec.Step] = rec_a.Values[rec_a.IndexOfKey(rec.Step)] + "," + rec.Recipient;
                    }

                    //步骤处理人赋值
                    for (int i = 0; i < rec_a.Keys.Count; i++)
                    {
                        TaskAPI["R_" + rec_a.Keys[i].Replace(" ", "_")] = rec_a.Values[i].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    }

                    bool falg_dt = false;
                    TaskDB db = new TaskDB();
                    db.Storage("bpmDB");
                    DataTable dt = db.Query(" select steplabel from  TASKS where processname='" + TaskAPI.Process + "' and  Incident=" + TaskAPI.Incident + " ");
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i][0].ToString() == "S")
                            {
                                falg_dt = true;
                                break;
                            }
                        }
                    }
                    if (falg_dt)
                    {
                        VD_DR2.ReadOnly = true;
                    }
                    string winId = "";
                    if (!string.IsNullOrEmpty(VD_DR2.Text.Trim()))
                    {
                        m_DR2 dr2 = (m_DR2.name == VD_DR2.Text.Trim()).ListFirst<m_DR2>();
                        if (dr2 != null)
                        {
                            winId = dr2.WinId;
                        }
                        else
                        {
                            Anthem.Manager.AddScriptForClientSideEval("JSInfomation('Vendor：DR2 必须填写正确！',false)");
                            return;
                        }
                    }
                    m_OrgChart oc = (m_OrgChart.empID.In(m_OrgChart.dr2EmpID, m_OrgChart.winID == UserAPI.UserName)).ListFirst<m_OrgChart>();
                    if (oc != null)
                    {
                        if (!falg_dt)
                        {
                            //if (TaskAPI["R_Manager_Approve2"] != null)
                            //{
                            //    object[] obj1 = (object[])(TaskAPI["R_Manager_Approve2"]);
                            //    for (int i = 0; i <= obj1.GetUpperBound(0); i++)
                            //    {
                            //        obj1[i] = null;
                            //    }
                            //    TaskAPI["R_Manager_Approve2"] = obj1;
                            //}
                            if (!string.IsNullOrEmpty(this.VD_DR2.Text.Trim()))
                            {

                                TaskAPI["R_Manager_Approve2"] = winId;
                            }
                            else
                            {
                                TaskAPI["R_Manager_Approve2"] = oc.WinID;
                            }
                        }


                    }

                    #endregion
                }
                else
                {
                    TaskAPI["ApproveResult"] = Assessment1.Assessment.Opinion;
                    TaskAPI["TaskID"] = TaskAPI.TaskID;
                }

                if (TaskAPI.IsBeginStep && !TaskAPI.IsInitiate
                && (Action_Type != VD_Category.SelectedValue || Vendor_Type != VD_Vendor_Type.SelectedValue))
                {
                    string PreStep = ((object[])TaskAPI["PreStep"])[0].ToString();
                    if (PreStep.Trim() != "" && PreStep.Trim() != "Manager Approve")
                    {
                        TaskAPI["PreStep"] = "DMO Approve";
                    }
                }



                if (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit)
                {
                    TaskAPI["Vendor_Type"] = VD.Checked && VD_Vendor_Type.SelectedValue == "内部(Internal)" ? "Internal" : "External";
                    TaskAPI["VD"] = VD.Checked ? "1" : "0";
                }


                //#region 退回步骤并返回功能 传值
                //if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                //{
                //    TaskAPI["Step"] = Assessment1.JumpStep;
                //    TaskAPI["PreStep"] = TaskAPI.Step;
                //}
                //else
                //{
                //    string PreStep = ((object[])TaskAPI["PreStep"])[0].ToString();
                //    if (PreStep.Trim() != "")
                //    {
                //        TaskAPI["Step"]    = PreStep;
                //        TaskAPI["PreStep"] = "";
                //    }
                //    else
                //    {
                //        TaskAPI["Step"] = "";
                //        TaskAPI["PreStep"] = "";
                //    }
                //}
                //#endregion

                #endregion

                #region 提交步骤
                bool flg = false;
                Storage.TransactionExecute(o =>
                {
                    #region “Fill in the form”步骤
                    if (TaskAPI.IsBeginStep || TaskAPI.Step == "Finance")
                    {
                        (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident).Edit<nvd_Vendor>(p =>
                        {
                            p.Status = 1;
                        }
                        );
                        //nvd_Vendor vendor = new nvd_Vendor();
                        //if ((nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident).Count<nvd_Vendor>() > 0)
                        //{
                        //    vendor = (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident).ListFirst<nvd_Vendor>();
                        //}
                        //else
                        //{
                        //    vendor.Process       = TaskAPI.Process;
                        //    vendor.Incident      = TaskAPI.Incident;
                        //    vendor.UserName      = UserAPI.UserName;
                        //    vendor.UserFullName  = UserAPI.UserFullName;
                        //    vendor.ApplicationNo = ApplicationNo.Text;
                        //    vendor.Time          = System.DateTime.Now;
                        //    vendor.Status        = 0;
                        //    vendor.Department    = UserAPI.Department;
                        //}
                        nvd_Vendor vendor = new nvd_Vendor();
                        if (TaskAPI.IsBeginStep)
                        {
                            if ((nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident & nvd_Vendor.user == TaskAPI.UserName).Count<nvd_Vendor>() > 0)
                            {
                                vendor = (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident & nvd_Vendor.user == TaskAPI.UserName).ListFirst<nvd_Vendor>();
                            }
                            vendor.Process = TaskAPI.Process;
                            vendor.Incident = TaskAPI.Incident;
                            vendor.UserName = UserAPI.UserName;
                            vendor.UserFullName = UserAPI.UserFullName;
                            vendor.ApplicationNo = ApplicationNo.Text;
                            vendor.Time = System.DateTime.Now;
                            vendor.Status = 0;
                            vendor.Department = UserAPI.Department;
                        }
                        else if (TaskAPI.Step == "Finance")
                        {
                            if ((nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident & nvd_Vendor.user == TaskAPI["Applicator"]).Count<nvd_Vendor>() > 0)
                            {
                                vendor = (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident & nvd_Vendor.user == TaskAPI["Applicator"]).ListFirst<nvd_Vendor>();
                            }
                        }

                        vendor.VD_Category = VD_Category.SelectedValue;
                        vendor.Actions = VD_Category.SelectedItem.Text;
                        vendor.DrpPriority = DrpPriority.SelectedValue;


                        vendor.VD_Checked = VD.Checked ? "1" : "0";
                        vendor.SA_Checked = SA.Checked ? "1" : "0";
                        vendor.SA2_Checked = SA2.Checked ? "1" : "0";
                        //vendor.DMO_Employee_Name = DMO_Employee_Name.Text;
                        //vendor.DMO_ID_Card = DMO_ID_Card.Text;

                        #region VD
                        if (VD.Checked)
                        {
                            vendor.VD_Company = VD_Company.SelectedValue;
                            vendor.VD_Vendor_Type = VD_Vendor_Type.SelectedValue;
                            vendor.VD_YY = VD_YY.Checked ? "1" : "0";
                            vendor.VD_Description_1 = VD_Description_1.Text;
                            vendor.VD_Description_2 = VD_Description_2.Text;
                            vendor.VD_Search_Term = VD_Search_Term.Text;
                            vendor.VD_Street = VD_Street.Text;
                            vendor.VD_Country = VD_Country.Text;
                            vendor.VD_Region = VD_Region.SelectedValue;
                            vendor.VD_City = VD_City.Text;
                            vendor.VD_Street5 = VD_Street5.Text;
                            vendor.VD_District = VD_District.Text;
                            vendor.VD_Street4 = VD_Street4.Text;
                            vendor.VD_Postal_Code = VD_Postal_Code.Text;
                            vendor.VD_Language = VD_Language.SelectedValue;
                            vendor.VD_Contact_Person = VD_Contact_Person.Text;
                            vendor.VD_Telephone = VD_Telephone.Text;
                            vendor.VD_Ext_1 = VD_Ext_1.Text;
                            vendor.VD_Fax_Number = VD_Fax_Number.Text;
                            vendor.VD_Ext_2 = VD_Ext_2.Text;
                            vendor.VD_Email = VD_Email.Text;
                            vendor.VD_Schema_Group = VD_Schema_Group.SelectedValue;
                            vendor.VD_GR_Based = VD_GR_Based.Checked ? "1" : "0";
                            vendor.VD_Confirmation_Control = VD_Confirmation_Control.SelectedValue;
                            vendor.VD_PI = VD_PI.SelectedValue;
                            vendor.VD_Bank_Country = VD_Bank_Country.Text;
                            vendor.VD_Bank_Name = VD_Bank_Name.Text;
                            vendor.VD_Bank_Account = VD_Bank_Account.Text;
                            vendor.VD_Recon_Account = VD_Recon_Account.SelectedValue;
                            vendor.VD_Cash_Mgmnt_Group = VD_Cash_Mgmnt_Group.SelectedValue;
                            vendor.VD_Payt_Terms = VD_Payt_Terms.SelectedValue;
                            vendor.VD_Payment_Methods = getFormCheckList(VD_Payment_Methods);
                            vendor.VD_Acctg_Clerk = VD_Acctg_Clerk.SelectedValue;
                            vendor.VD_Order_Currency = VD_Order_Currency.Text;
                            vendor.VD_Payment_Terms = VD_Payment_Terms.SelectedValue;
                            vendor.VD_Purchasing_Group = VD_Purchasing_Group.SelectedValue;
                            vendor.VD_Pricing_Date_Control = VD_Pricing_Date_Control.Text;
                            vendor.VD_Acct_statement = VD_Acct_statement.Text;
                            vendor.VD_Category = VD_Category.Text;
                            vendor.VD_Area = VD_Area1.Checked ? "1" : (VD_Area2.Checked ? "2" : "3");
                            vendor.VD_Vendor_Master_Code = VD_Vendor_Master_Code.Text;
                            vendor.VD_Customer_sold_to_code = VD_Customer_sold_to_code.Text;
                        }
                        #endregion

                        #region SA
                        if (SA.Checked)
                        {
                            vendor.SA_Temp_Staff = SA_Temp_Staff.Checked ? "1" : "0";
                            vendor.SA_Vendor_Master_Code = SA_Vendor_Master_Code.Text;
                            vendor.SA_Name = SA_Name.Text;
                            vendor.SA_Company = SA_Company.Text;
                            vendor.SA_Gender = SA_Gender.SelectedValue;
                            vendor.SA_Nationality = SA_Nationality.Text;
                            vendor.SA_ID_No = SA_ID_No.Text;
                            vendor.SA_Region = SA_Region.Text;
                            vendor.SA_City = SA_City.Text;
                            vendor.SA_District = SA_District.Text;
                            vendor.SA_Street = SA_Street.Text;
                            vendor.SA_Postal_Code = SA_Postal_Code.Text;
                            vendor.SA_Telephone = SA_Telephone.Text;
                            vendor.SA_Ext_3 = SA_Ext_3.Text;
                            vendor.SA_Cell_Phone = SA_Cell_Phone.Text;
                            vendor.SA_Fax_Number = SA_Fax_Number.Text;
                            vendor.SA_Email = SA_Email.Text;
                            vendor.SA_Bank_Name = SA_Bank_Name.Text;
                            vendor.SA_Bank_Country = SA_Bank_Country.Text;

                            vendor.SA_SWIFT_BINN = SA_SWIFT_BINN.Text;
                            vendor.SA_Bank_Account = SA_Bank_Account.Text;
                            vendor.SA_Sales_Person = SA_Sales_Person.SelectedValue;
                            vendor.SA_Employment_Date = SA_Employment_Date.Text;
                            vendor.SA_Personnel_Area = SA_Personnel_Area.Text;
                            vendor.SA_EE_Group = SA_EE_Group.SelectedValue;
                            vendor.SA_EE_Su_Group = SA_EE_Su_Group.Text;
                            vendor.SA_Subarea = SA_Subarea.SelectedValue;

                            vendor.SA_Expense_User = SA_Expense_User.Checked ? "1" : "0";
                            vendor.SA_Expense_Approver = SA_Expense_Approver.Checked ? "1" : "0";
                            vendor.SA_State_Province = SA_State_Province.SelectedValue;
                            vendor.SA_Legal_Entity = SA_Legal_Entity.SelectedValue;
                            vendor.SA_Location = SA_Location.SelectedValue;

                            vendor.SA_Employee_Grouping = SA_Employee_Grouping.Text;
                            vendor.SA_Employee_Group_Configuration = SA_Employee_Group_Configuration.Text;
                            vendor.SA_First_Name = SA_First_Name.Text;
                            vendor.SA_Last_Name = SA_Last_Name.Text;
                            vendor.SA_CTE_Login_Name = SA_CTE_Login_Name.Text;
                            vendor.SA_Account_Activation_Date = SA_Account_Activation_Date.Text;
                            vendor.SA_Account_Termination_Date = SA_Account_Termination_Date.Text;
                            vendor.SA_Employee_ID = SA_Employee_ID.Text;
                            vendor.SA_Email_Address = SA_Email_Address.Text;
                            vendor.SA_Country = SA_Country.Text;
                            vendor.SA_Ledger = SA_Ledger.Text;
                            vendor.SA_Cost_Object_Type = SA_Cost_Object_Type.Text;
                            vendor.SA_ERP_ID = SA_ERP_ID.Text;
                            vendor.SA_Currency = SA_Currency.Text;
                            vendor.SA_Cost_Object_Code = SA_Cost_Object_Code.Text;
                            vendor.SA_Approver_Linemanager = SA_Approver_Linemanager.Text;
                            vendor.SA_SWIFT_BIN = SA_SWIFT_BIN.Text;
                            vendor.SA_Bank_Country_Concur = SA_Bank_Country_Concur.Text;
                            vendor.SA_IBAN_Number = SA_IBAN_Number.Text;
                            vendor.SA_Local_Personnel_Number = SA_Local_Personnel_Number.Text;
                            vendor.SA_Pay_Roll_ID = SA_Pay_Roll_ID.Text;
                            vendor.SA_Region_Concur = SA_Region_Concur.Text;
                            vendor.SA_Country_Concur = SA_Country_Concur.Text;
                            vendor.SA_Travel_Rule = SA_Travel_Rule.Text;
                            vendor.SA_Business_Area = SA_Business_Area.Text;
                            vendor.SA_Business_Unit = SA_Business_Unit.Text;
                            vendor.SA_Sub_Business_Unit = SA_Sub_Business_Unit.Text;
                            vendor.SA_Default_Lanuage = SA_Default_Lanuage.Text;


                        }
                        #endregion

                        #region SA2
                        if (SA2.Checked)
                        {
                            vendor.SA2_Personnel_NO = SA2_Personnel_NO.Text;
                            vendor.SA2_From_Date = SA2_From_Date.Text;
                            vendor.SA2_Personnel_Area = SA2_Personnel_Area.SelectedValue;
                            vendor.SA2_Company = SA2_Company.SelectedValue;
                            vendor.SA2_EE_Group = SA2_EE_Group.SelectedValue;
                            vendor.SA2_EE_Sub_Group = SA2_EE_Sub_Group.Text;
                            vendor.SA2_Subarea = SA2_Subarea.SelectedValue;
                            vendor.SA2_Last_Name = SA2_Last_Name.Text;
                            vendor.SA2_First_Name = SA2_First_Name.Text;
                            vendor.SA2_Gender = SA2_Gender.SelectedValue;
                            vendor.SA2_ID_NO = SA2_ID_NO.Text;

                            vendor.SA2_Birth_Date = SA2_Birth_Date.Text;
                            vendor.SA2_Sales_Organization = SA2_Sales_Organization.Text;
                            vendor.SA2_Sales_Office = SA2_Sales_Office.SelectedValue;
                            vendor.SA2_Position = SA2_Position.SelectedValue;
                            vendor.SA2_PerNo_Super = SA2_PerNo_Super.Text;
                            vendor.SA2_Nationality = SA2_Nationality.Text;
                            vendor.SA2_Street_And_HseNo = SA2_Street_And_HseNo.Text;
                            vendor.SA2_City = SA2_City.Text;
                            vendor.SA2_Mobile_Phone_Number = SA2_Mobile_Phone_Number.Text;
                            vendor.SA2_EMail_Address = SA2_EMail_Address.Text;
                        }
                        #endregion

                        (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });

                        Storage.Save(Storage.Context1, vendor);
                    }
                    #endregion

                    #region Priority功能
                    if (TaskAPI.IsBeginStep && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = new mdc_Priority();
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = new mdc_Priority();
                            pro.Process = TaskAPI.Process;
                            pro.Incident = TaskAPI.Incident;
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }

                    }


                    if ((TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check") && !string.IsNullOrEmpty(this.DMO_DrpPriority.SelectedValue) && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {

                        //mdc_Priority pro;
                        //pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                        //pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                        //Storage.Save(pro);
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }


                    }
                    #endregion

                    #region “DMO Maintain”步骤
                    if (TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check")
                    {
                        TaskAPI["DMO_DrpPriority"] = DMO_DrpPriority.SelectedItem.Text;
                        (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == TaskAPI.Incident).Edit<nvd_Vendor>(p =>
                        {

                            p.SAP_Code = SAP_Code.Text;
                            p.DMO_Arrpvoe_Creation_Number = DMO_Arrpvoe_Creation_Number.Text;
                            p.DMO_DrpPriority = DMO_DrpPriority.SelectedValue;
                            p.DMO_Arrpvoe_Creation_Time = DMO_Arrpvoe_Creation_Time.Text;
                            p.DMO_Maintain_Creation_Number = DMO_Maintain_Creation_Number.Text;
                            p.DMO_Maintain_Creation_Time = DMO_Maintain_Creation_Time.Text;
                            p.DMO_Check_Creation_Number = DMO_Check_Creation_Number.Text;
                            p.DMO_Check_Creation_Time = DMO_Check_Creation_Time.Text;
                            p.DMO_Arrpvoe_Revision_Number = DMO_Arrpvoe_Revision_Number.Text;
                            p.DMO_Arrpvoe_Revision_Time = DMO_Arrpvoe_Revision_Time.Text;
                            p.DMO_Maintain_Revision_Number = DMO_Maintain_Revision_Number.Text;
                            p.DMO_Maintain_Revision_Time = DMO_Maintain_Revision_Time.Text;
                            p.DMO_Check_Revision_Number = DMO_Check_Revision_Number.Text;
                            p.DMO_Check_Revision_Time = DMO_Check_Revision_Time.Text;

                            p.DMO_SalesSAP_Code = DMO_SalesSAP_Code.Text;
                        }
                        );
                    }
                    #endregion
                    #region DMO Check 步骤
                    if (TaskAPI.Step == "DMO Check" && Assessment1.Assessment.Opinion == "1")
                    {
                        (m_VendorMaster.vendor_Code == SAP_Code.Text).Edit<m_VendorMaster>(p =>
                        {
                            p.Status = 1;
                        }
                        );
                        m_VendorMaster m_vm = new m_VendorMaster();
                        if ((m_VendorMaster.vendor_Code == SAP_Code.Text).Count<m_VendorMaster>() > 0)
                        {
                            m_vm = (m_VendorMaster.vendor_Code == SAP_Code.Text).ListFirst<m_VendorMaster>();
                        }
                        else
                        {
                            m_vm.Status = 1;
                        }

                        m_vm.Vendor_Code = SAP_Code.Text;
                        m_vm.Site = "CN";
                        m_vm.Vendor_Name = DMO_Employee_Name.Text;
                        if (SA.Checked)
                        {
                            m_vm.Vendor_Type = "EMP";
                        }
                        else
                        {
                            m_vm.Vendor_Type = "VND";
                        }
                        //Jacky添加
                        if (DMO_ID_Card.Text != "")
                        {
                            m_vm.ID_Card = DMO_ID_Card.Text;
                        }
                        //m_vm.ID_Card = DMO_ID_Card.Text;

                        if (VD_Category.SelectedValue == "1")
                        {
                            m_vm.Sales_SAP_Code = DMO_SalesSAP_Code.Text;
                            m_vm.CreateDate = System.DateTime.Now;
                        }
                        if (VD_Category.SelectedValue == "3")
                        {
                            m_vm.UpdateDate = System.DateTime.Now;
                            m_vm.Status = 0;
                        }
                        else if (VD_Category.SelectedValue == "2")
                        {
                            m_vm.UpdateDate = System.DateTime.Now;
                        }

                        Storage.Save(Storage.Context1, m_vm);
                    }
                    #endregion

                    Storage.Save(Assessment1.Assessment);    //审批意见  
                });

                //多节点退回
                if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                {
                    Assessment1.SetAsReturn(true);
                    TaskAPI.DirectActive(Assessment1.JumpStep);
                }
                else
                {
                    Assessment1.SetAsReturn(false);
                }
                Assessment1.SubmitTo();

                flg = TaskAPI.Send();

                //如果数据库写入成功且流程发起成功的情况，将业务表数据与流程实例号进行关联
                if (TaskAPI.IsInitiate)
                {
                    if (!string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == 0).Edit<mdc_Priority>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });
                    }
                    (nvd_Vendor.process == TaskAPI.Process & nvd_Vendor.incident == 0 & nvd_Vendor.user == UserAPI.UserName).Edit<nvd_Vendor>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Assessment.process == TaskAPI.Process & t_Assessment.incident == 0 & t_Assessment.assignedToUserName == UserAPI.UserName).Edit<t_Assessment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });
                }
                #endregion

                Send.Visible = false;
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Success + "',true)");
            }
            catch (Exception ex)
            {
                TaskDB.Log("", false, "调用NVA方法Send_Click出错：" + ex.ToString());
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Failed + "',false)");
            }
        }
        #endregion

        #region 事件 CheckedChanged
        protected void VD_CheckedChanged(object sender, EventArgs e)
        {
            SetVisible(false, P_VD, P_SA, P_SA2);
            switch (((Anthem.CheckBox)sender).ID)
            {
                case "VD":

                    if (VD.Checked)
                    {
                        SA.Checked = false;
                        SA2.Checked = false;
                    }
                    VD.Checked = !(SA.Checked | SA2.Checked);
                    VD_L.Visible = VD.Checked;
                    break;
                case "SA":
                    if (!SA.Checked & !SA2.Checked) SA.Checked = true;
                    VD.Checked = !(SA.Checked | SA2.Checked);
                    SA_L.Visible = SA.Checked;
                    if (!SA.Checked & SA2.Checked) { SA2_L.CssClass = "tabs1"; Tabs_Click(SA2_L, e); }
                    break;
                case "SA2":

                    if (!SA.Checked & !SA2.Checked) SA2.Checked = true;
                    VD.Checked = !(SA.Checked | SA2.Checked);
                    if (SA2.Checked & VD_Category.SelectedValue != "2") { SA_Email_L.ForeColor = Color.Blue; }
                    else { SA_Email_L.ForeColor = Color.Black; }
                    SA2_L.Visible = SA2.Checked;


                    break;
            }
            if (SA2.Checked) { SA_Sales_Person.SelectedValue = "Y"; }
            else SA_Sales_Person.SelectedValue = "N";
            InitTabs();
        }
        #endregion

        #region 事件 Category变换
        protected void VD_Category_SelectedIndexChanged(object sender, EventArgs e)
        {
            //SetEnable(!(VD_Category.SelectedValue == "3" || VD_Category.SelectedValue == "4"), VD_Company, VD_Vendor_Type, VD_Description_1, VD_Description_2, VD_Search_Term, VD_Street, VD_Country, VD_Region, VD_City, VD_Street5, VD_District, VD_Street4, VD_Postal_Code, VD_Language, VD_Contact_Person, VD_Telephone, VD_Ext_1, VD_Fax_Number, VD_Ext_2, VD_Email, VD_Bank_Country, VD_Bank_Name, VD_Bank_Account, VD_Recon_Account, VD_Cash_Mgmnt_Group, VD_Payt_Terms, VD_Payment_Methods, VD_Acctg_Clerk, VD_Order_Currency, VD_Payment_Terms, VD_Purchasing_Group, VD_Area1, VD_Area2, VD_Area3, VD_Customer_sold_to_code, SA_Name, SA_Company, SA_Gender, SA_Nationality, SA_ID_No, SA_Region, SA_City, SA_District, SA_Street, SA_Postal_Code, SA_Telephone, SA_Ext_3, SA_Cell_Phone, SA_Fax_Number, SA_Email, SA_Bank_Name, SA_Bank_Country, SA_Bank_Account, SA_Sales_Person, SA_Employment_Date, SA_Personnel_Area, SA_EE_Group, SA2_From_Date, SA2_Personnel_Area, SA2_EE_Group, SA2_Subarea, SA2_Last_Name, SA2_First_Name, SA2_Gender, SA2_Birth_Date, SA2_Street_And_HseNo, SA2_City, SA2_Mobile_Phone_Number, SA2_EMail_Address, SA_Temp_Staff, SAP_Code, SA_Subarea);
            SetEnable((VD_Category.SelectedValue == "1" || VD_Category.SelectedValue == "2" || VD_Category.SelectedValue == "3" || VD_Category.SelectedValue == "4"), DrpPriority, VD_YY, VD_Company, VD_Description_1, VD_Description_2, VD_Search_Term, VD_Street, VD_Country, VD_Region, VD_City, VD_Street5, VD_District, VD_Street4, VD_Postal_Code, VD_Language, VD_Contact_Person, VD_Telephone, VD_Ext_1, VD_Fax_Number, VD_Ext_2, VD_Schema_Group, VD_PI, VD_Confirmation_Control, VD_Email, VD_Bank_Country, VD_Bank_Name, VD_Bank_Account, VD_Recon_Account, VD_Cash_Mgmnt_Group, VD_Payt_Terms, VD_Payment_Methods, VD_Acctg_Clerk, VD_Order_Currency, VD_Payment_Terms, VD_Purchasing_Group, VD_Area1, VD_Area2, VD_Area3, VD_Customer_sold_to_code, SA_Name, SA_Company, SA_Gender, SA_Nationality, SA_ID_No, SA_Region, SA_City, SA_District, SA_Street, SA_Postal_Code, SA_Telephone, SA_Ext_3, SA_Cell_Phone, SA_Fax_Number, SA_Email, SA_Bank_Name, SA_Bank_Country, SA_SWIFT_BINN, SA_Bank_Account, SA_Sales_Person, SA_Employment_Date, SA_Personnel_Area, SA_EE_Group, SA2_From_Date, SA2_Personnel_Area, SA2_Company, SA2_EE_Group, SA2_Subarea, SA2_Last_Name, SA2_First_Name, SA2_Gender, SA2_ID_NO, SA2_Birth_Date, SA2_Street_And_HseNo, SA2_City, SA2_Mobile_Phone_Number, SA2_EMail_Address, SA_Temp_Staff, SAP_Code, SA_Subarea, SA2_Sales_Office, SA2_Position, SA2_PerNo_Super, SA2_Sales_Organization, SA_Expense_Approver, SA_First_Name, SA_Last_Name, SA_CTE_Login_Name, SA_Account_Activation_Date, SA_Account_Termination_Date, SA_Employee_ID, SA_State_Province, SA_Legal_Entity, SA_Cost_Object_Code, SA_Approver_Linemanager, SA_SWIFT_BIN, SA_IBAN_Number, SA_Location);
            SetVisible(VD_Category.SelectedValue != "1", P1, P2, P3);
            //SetVisible(!SA_Temp_Staff.Checked, P_Concur);
            SetVisible(VD_Category.SelectedValue == "1", P5);
            if (VD_Area3.Checked) VD_Area_CheckedChanged(VD_Area3, e);
        }
        #endregion

        #region 事件 Sales_Person
        protected void SA_Sales_Person_SelectedIndexChanged(object sender, EventArgs e)
        {
            SA2.Checked = SA_Sales_Person.SelectedValue == "Y";
            VD_CheckedChanged(SA2, e);
            InitTabs();
        }
        #endregion

        #region 事件 Area
        protected void VD_Area_CheckedChanged(object sender, EventArgs e)
        {
            VD_Area1.Checked = false;
            VD_Area2.Checked = false;
            VD_Area3.Checked = false;
            SetForeColor(Color.Black, VD_Telephone_L, VD_Fax_Number_L);

            switch ((sender as Anthem.CheckBox).ID)
            {
                case "VD_Area1":
                    VD_Area1.Checked = true;
                    break;

                case "VD_Area2":
                    VD_Area2.Checked = true;
                    break;

                case "VD_Area3":
                    if (VD_Category.SelectedValue == "2")
                    {
                        SetForeColor(Color.Black, VD_Telephone_L, VD_Fax_Number_L);
                    }
                    else
                    {
                        SetForeColor(Color.Blue, VD_Telephone_L, VD_Fax_Number_L);
                    }
                    VD_Area3.Checked = true;
                    break;
            }
        }
        #endregion

        #region Payt_Terms
        protected void VD_Payt_Terms_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch ((sender as Anthem.DropDownList).ID)
            {
                case "VD_Payt_Terms":
                    if (VD_Category.SelectedValue == "1")
                        VD_Payment_Terms.SelectedValue = VD_Payt_Terms.SelectedValue;
                    break;

                case "VD_Payment_Terms":
                    VD_Payt_Terms.SelectedValue = VD_Payment_Terms.SelectedValue;
                    break;
            }
        }
        #endregion

        #region 事件 Tabs切换
        protected void Tabs_Click(object sender, EventArgs e)
        {
            if (((LinkButton)sender).CssClass == "tabs2")
            {
                return;
            }

            #region 初始化
            SetVisible(false, P_VD, P_SA, P_SA2);
            VD_L.CssClass = "tabs1";
            SA_L.CssClass = "tabs1";
            SA2_L.CssClass = "tabs1";
            #endregion

            #region Tabs切换动作
            switch (((LinkButton)sender).ID)
            {
                case "VD_L":
                    VD_L.CssClass = "tabs2";
                    P_VD.Visible = true;
                    break;
                case "SA_L":
                    SA_L.CssClass = "tabs2";
                    P_SA.Visible = true;
                    break;
                case "SA2_L":
                    SA2_L.CssClass = "tabs2";
                    P_SA2.Visible = true;
                    break;
            }
            #endregion
        }
        #endregion

        #region 方法 初始化Tabs
        protected void InitTabs()
        {
            VD_L.Visible = VD.Checked;
            SA_L.Visible = SA.Checked;
            SA2_L.Visible = SA2.Checked;

            SetVisible(false, P_VD, P_SA, P_SA2);
            VD_L.CssClass = "tabs1";
            SA_L.CssClass = "tabs1";
            SA2_L.CssClass = "tabs1";

            //默认第1个显示 Tabs被选中
            if (VD_L.Visible)
            {
                VD_L.CssClass = "tabs2";
                P_VD.Visible = true;
                return;
            }

            if (SA_L.Visible)
            {
                SA_L.CssClass = "tabs2";
                P_SA.Visible = true;
                return;
            }

            if (SA2_L.Visible)
            {
                SA2_L.CssClass = "tabs2";
                P_SA2.Visible = true;
                return;
            }
        }
        #endregion

        #region 方法 InitDropdownList
        private void InitDropDownList()
        {
            if (!IsLoaded)
            {
                VD_Recon_Account.Items.Clear();
                VD_Recon_Account.Items.Add(new ListItem("", ""));
                IList<m_Vender_Recon_Account> vras = (m_Vender_Recon_Account.status == 1).List<m_Vender_Recon_Account>();
                foreach (m_Vender_Recon_Account vra in vras)
                {
                    VD_Recon_Account.Items.Add(new ListItem(vra.Recon_Account + ", " + vra.Description, vra.Recon_Account));
                }

                VD_Payt_Terms.Items.Clear();
                VD_Payt_Terms.Items.Add(new ListItem("", ""));
                VD_Payment_Terms.Items.Clear();
                VD_Payment_Terms.Items.Add(new ListItem("", ""));
                IList<m_Payment_Terms> pts = (m_Payment_Terms.status == 1).List<m_Payment_Terms>();
                foreach (m_Payment_Terms pt in pts)
                {
                    VD_Payt_Terms.Items.Add(new ListItem(pt.Code + ", " + pt.Baseline_Date, pt.Code));
                    VD_Payment_Terms.Items.Add(new ListItem(pt.Code + ", " + pt.Baseline_Date, pt.Code));
                }

                VD_Purchasing_Group.Items.Clear();
                VD_Purchasing_Group.Items.Add(new ListItem("", ""));
                IList<m_PurchasingGroup> pgs = (m_PurchasingGroup.status == 1).List<m_PurchasingGroup>();
                foreach (m_PurchasingGroup pg in pgs)
                {
                    VD_Purchasing_Group.Items.Add(new ListItem(pg.Purchase_Group + ", " + pg.Description, pg.Purchase_Group));
                }

                VD_Schema_Group.Items.Clear();
                VD_Schema_Group.Items.Add(new ListItem("", ""));
                IList<m_Schema_Group> pts2 = (m_Schema_Group.status == 1).List<m_Schema_Group>();
                foreach (m_Schema_Group pt in pts2)
                {
                    VD_Schema_Group.Items.Add(new ListItem(pt.Schema_Group, pt.Schema_Group));
                }

                VD_Confirmation_Control.Items.Clear();
                VD_Confirmation_Control.Items.Add(new ListItem("", ""));
                IList<m_Confirmation_Control> pts3 = (m_Confirmation_Control.status == 1).List<m_Confirmation_Control>();
                foreach (m_Confirmation_Control pt in pts3)
                {
                    VD_Confirmation_Control.Items.Add(new ListItem(pt.Confirmation_Control, pt.Confirmation_Control));
                }

                VD_PI.Items.Clear();
                VD_PI.Items.Add(new ListItem("", ""));
                IList<m_PI> pts4 = (m_PI.status == 1).List<m_PI>();
                foreach (m_PI pt in pts4)
                {
                    VD_PI.Items.Add(new ListItem(pt.PI, pt.PI));
                }

                SA2_Position.Items.Clear();
                SA2_Position.Items.Add(new ListItem("", ""));
                IList<m_SalesPerson_Title> vras1 = (m_SalesPerson_Title.status == 1).List<m_SalesPerson_Title>();
                foreach (m_SalesPerson_Title vra in vras1)
                {
                    SA2_Position.Items.Add(new ListItem(vra.Title, vra.Title));
                }

                SA_State_Province.Items.Clear();
                SA_State_Province.Items.Add(new ListItem("", ""));
                IList<m_State_Province> vras2 = (m_State_Province.status == 1).List<m_State_Province>();
                foreach (m_State_Province vra in vras2)
                {
                    SA_State_Province.Items.Add(new ListItem(vra.State_Province, vra.State_Province));
                }

                SA_Location.Items.Clear();
                SA_Location.Items.Add(new ListItem("", ""));
                IList<m_Vendor_Location> vras3 = (m_Vendor_Location.status == 1).List<m_Vendor_Location>();
                foreach (m_Vendor_Location vra in vras3)
                {
                    SA_Location.Items.Add(new ListItem(vra.Location, vra.Location));
                }
                IsLoaded = true;
            }
        }
        #endregion

        #region 方法 数据验证
        private List<string> DataValidation()
        {
            #region VD
            List<Regular> regs = new List<Regular>();
            if (VD.Checked && (SA.Checked | SA2.Checked)) { regs.Add(new Regular(RegularExp.NotEmpty, "", "Vendor: 选择了Employee或Sales Person 则不能选Vendor")); }
            if (VD.Checked && VD_Category.SelectedValue == "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Company.SelectedValue, "Vendor: Company 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Vendor_Type.SelectedValue, "Vendor: Vendor Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Description_1.Text + VD_Description_2.Text, "Vendor: Description 1 (EN) 或 Vendor: Description 2 (CN)至少需要填写 1 个"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Search_Term.Text, "Vendor: Search Term 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Street.Text, "Vendor: Street 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Country.Text, "Vendor: Country 必填"));
                //regs.Add(new Regular(RegularExp.NotEmpty, VD_Region.SelectedValue, "Vendor: Region 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_City.Text, "Vendor: City 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Language.SelectedValue, "Vendor: Language 必填"));
                if (VD_Area3.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, VD_Telephone.Text, "Vendor: Telephone 必填"));
                    regs.Add(new Regular(RegularExp.NotEmpty, VD_Fax_Number.Text, "Vendor: Fax Number 必填"));
                }
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Bank_Country.Text, "Vendor: Bank Country 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Bank_Name.Text, "Vendor: Bank Name 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Bank_Account.Text, "Vendor: Bank Account 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Recon_Account.SelectedValue, "Vendor: Recon. Account 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Cash_Mgmnt_Group.SelectedValue, "Vendor: Cash Mgmnt Group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Payt_Terms.SelectedValue, "Vendor: Payt Terms 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Payment_Methods.SelectedValue, "Vendor: Payment Methods 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Acctg_Clerk.SelectedValue, "Vendor: Acctg Clerk 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Order_Currency.Text, "Vendor: Order Currency 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Payment_Terms.SelectedValue, "Vendor: Payment Terms 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Purchasing_Group.SelectedValue, "Vendor: Purchasing Group 必填"));
                if (!string.IsNullOrEmpty(this.VD_DR2.Text.Trim()))
                {
                    //m_OrgChart oc = (m_OrgChart.empID.In(m_OrgChart.dr2EmpID, m_OrgChart.winID == ViewState["winId"].ToString())).ListFirst<m_OrgChart>();
                    //if (ViewState["winId"] == null)
                    //{
                    //    regs.Add(new Regular(RegularExp.NotEmpty, "", "Vendor：DR2 必须填写正确！"));
                    //}
                }

            }

            if (VD.Checked && VD_Category.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Vendor_Master_Code.Text, "Vendor: Vendor 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Vendor_Type.SelectedValue, "Vendor: Vendor Type 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Description_1.Text + VD_Description_2.Text, "Vendor: Description 1 (EN) 或 Vendor: Description 2 (CN)至少需要填写 1 个"));
                regs.Add(new Regular(RegularExp.NotEmpty, VD_Company.SelectedValue, "Vendor: Company 必填"));
                if (!string.IsNullOrEmpty(this.VD_DR2.Text.Trim()))
                {
                    //m_OrgChart oc = (m_OrgChart.empID.In(m_OrgChart.dr2EmpID, m_OrgChart.winID == ViewState["winId"].ToString())).ListFirst<m_OrgChart>();
                    //if (ViewState["winId"] == null)
                    //{
                    //    regs.Add(new Regular(RegularExp.NotEmpty, "", "Vendor: DR2 必须填写正确！"));
                    //}
                }

            }
            #endregion

            #region SA
            if (SA.Checked && VD_Category.SelectedValue == "1")
            {

                regs.Add(new Regular(RegularExp.NotEmpty, SA_Company.Text, "Employee: Company 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Gender.SelectedValue, "Employee: Gender 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Nationality.Text, "Employee: Nationality 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_ID_No.Text, "Employee: ID No 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Region.Text, "Employee: Region 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_City.Text, "Employee: City 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Street.Text, "Employee: Street 必填"));

                //regs.Add(new Regular(RegularExp.NotEmpty, SA_Telephone.Text, "Employee: Telephone 必填"));

                //regs.Add(new Regular(RegularExp.NotEmpty, SA_Fax_Number.Text, "Employee: Fax Number 必填"));
                if (SA.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Name.Text, "Employee: Name 必填"));
                }
                if (SA2.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Email.Text, "Employee: Email 必填"));

                }

                regs.Add(new Regular(RegularExp.NotEmpty, SA_Cell_Phone.Text, "Employee: Cell Phone 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Bank_Name.Text, "Employee: Bank Name 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Bank_Country.Text, "Employee: Bank Country 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_SWIFT_BINN.Text, "Employee: SWIFT BINN 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Bank_Account.Text, "Employee: Bank Account 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Sales_Person.SelectedValue, "Employee: Sales Person 必填"));

                if (SA_SWIFT_BINN.Text.Length != 12)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "SWIFT/BIN 长度只能12位！"));
                }

                //if (!SA_Temp_Staff.Checked)
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_First_Name.Text, "Employee: First Name(名) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Last_Name.Text, "Employee: Last Name(姓) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_CTE_Login_Name.Text, "Employee: CTE Login Name（公司员工邮箱) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Account_Activation_Date.Text, "Employee: Account Activation Date (报销账号开始时间) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Employee_ID.Text, "Employee: Employee ID (HR系统中8位数值) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_State_Province.SelectedValue, "Employee: State/Province 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Legal_Entity.SelectedValue, "Employee: Legal Entity 公司代码(机构单位2) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Cost_Object_Code.Text, "Employee: Cost Object Code成本对象代码 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Approver_Linemanager.Text, "Employee: Approver (linemanager)(报销审批人邮箱) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_SWIFT_BIN.Text, "Employee: SWIFT/BIN (银行清算代码) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_IBAN_Number.Text, "Employee: IBAN number (银行账号号码) 必填"));
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_Location.SelectedValue, "Employee: Location 必填"));

                //    if (SA_Employee_ID.Text.Length != 8)
                //    {
                //        regs.Add(new Regular(RegularExp.NotEmpty, "", "Employee ID 长度只能8位！"));
                //    }

                //    if (SA_SWIFT_BIN.Text.Length != 12)
                //    {
                //        regs.Add(new Regular(RegularExp.NotEmpty, "", "SWIFT/BIN 长度只能12位！"));
                //    }

                //}
            }

            if (SA.Checked && VD_Category.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Vendor_Master_Code.Text, "Employee: Vendor Master Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Name.Text, "Employee: Name(CN 中文名) 必填"));

                //if (!SA_Temp_Staff.Checked)
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, SA_CTE_Login_Name.Text, "Employee: CTE Login Name（公司员工邮箱) 必填"));

                //if (SA_Employee_ID.Text.Length != 8)
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, "", "Employee ID 长度只能8位！"));
                //}

                //if (SA_SWIFT_BIN.Text.Length != 12)
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, "", "SWIFT/BIN 长度只能12位！"));
                //}
                // }
            }
            #endregion

            #region SA2
            if (SA2.Checked && VD_Category.SelectedValue == "1")
            {
                //regs.Add(new Regular(RegularExp.NotEmpty, SA2_Personnel_NO.Text, "Sales Person: Personnel NO 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_From_Date.Text, "Sales Person: From Date 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Personnel_Area.SelectedValue, "Sales Person: Personnel Area 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Company.SelectedValue, "Sales Person: Company 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_EE_Group.SelectedValue, "Sales Person: EE Group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_EE_Sub_Group.Text, "Sales Person: EE Sub Group 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Subarea.SelectedValue, "Sales Person: Subarea 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Last_Name.Text, "Sales Person: Last Name 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_First_Name.Text, "Sales Person: First Name 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Gender.SelectedValue, "Sales Person: Gender 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_ID_NO.Text, "Sales Person: ID No. 必填"));

                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Nationality.Text, "Sales Person: Nationality 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Sales_Office.SelectedValue, "Sales Person: Sales Office 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_City.Text, "Sales Person: City 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Mobile_Phone_Number.Text, "Sales Person: Mobile Phone Number 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_EMail_Address.Text, "Sales Person: EMail Address 必填"));
            }

            if (SA2.Checked && VD_Category.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, SA2_Personnel_NO.Text, "Sales Person: Personnel NO 必填"));
            }
            #endregion

            #region  修改SAP Code设置为必填
            //Tang Bin  修改SAP Code设置为必填
            if ((VD.Checked || SA.Checked) && VD_Category.SelectedValue == "1" && TaskAPI.Step == "DMO Maintain" && Assessment1.Assessment.Opinion == "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, SAP_Code.Text, "Sap Code 必填！"));
                if (VD.Checked && SAP_Code.Text.Length != 7 && VD_Vendor_Type.SelectedValue == "内部(Internal)")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "Sap Code 长度只能是7位！"));
                }
                if (VD.Checked && SAP_Code.Text.Length != 6 && VD_Vendor_Type.SelectedValue == "外部(External)")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "Sap Code 长度只能是6位！"));
                }
                if (SA.Checked && SAP_Code.Text.Length != 10)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "Sap Code 长度只能10是位！"));
                }
            }
            //TB添加
            if (TaskAPI.Step == "DMO Approve" & VD_Category.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Arrpvoe_Creation_Number.Text == "" | DMO_Arrpvoe_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Approve的Creation项必填"));
                }
                //if (SA2.Checked & VD_Category.SelectedValue == "1")
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, DMO_SalesSAP_Code.Text, "Sales SAP Code 必填"));
                //}
            }
            if (TaskAPI.Step == "DMO Maintain" & VD_Category.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Maintain_Creation_Number.Text == "" | DMO_Maintain_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Maintain的Creation项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Check" & VD_Category.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Check_Creation_Number.Text == "" | DMO_Check_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Check的Creation项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Approve" & VD_Category.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Arrpvoe_Revision_Number.Text == "" | DMO_Arrpvoe_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Approve的Revision项必填"));
                }
                //if (SA2.Checked & VD_Category.SelectedValue == "1")
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, DMO_SalesSAP_Code.Text, "Sales SAP Code 必填"));
                //}
            }
            if (TaskAPI.Step == "DMO Maintain" & VD_Category.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Maintain_Revision_Number.Text == "" | DMO_Maintain_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Maintain的Revision项必填"));
                }

            }

            if (TaskAPI.Step == "DMO Check" & VD_Category.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Check_Revision_Number.Text == "" | DMO_Check_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Check的Revision项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Maintain" & VD_Category.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {
                if ((m_VendorMaster.vendor_Code == SAP_Code.Text).Count<m_VendorMaster>() > 0)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", "SAP Code出现重复,请确认SAP Code是否正确"));
                }
            }
            #endregion
            return Validation(regs);
        }
        #endregion

        #region 方法 Others
        protected void VD_Payment_Methods_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        private string getFormCheckList(Anthem.CheckBoxList ck)
        {
            string t = "";
            for (int i = 0; i < ck.Items.Count; i++)
                if (ck.Items[i].Selected)
                    t += "," + ck.Items[i].Value;
                else
                    t += ",";
            return t;
        }
        private Anthem.CheckBoxList setCheckList(string t, Anthem.CheckBoxList ck)
        {
            try
            {
                string[] tt = t.Split(',');

                for (int i = 0; i <= tt.GetUpperBound(0); i++)
                {
                    for (int j = 0; j < ck.Items.Count; j++)
                    {
                        if (ck.Items[j].Value == tt[i].ToString())
                        { ck.Items[j].Selected = true; break; }
                    }
                }
            }
            catch { }
            return ck;
        }
        #endregion

        #region 方法 SetDropDownListValue
        private void SetDropDownListValue(Anthem.DropDownList drpT, object o)
        {
            try
            {
                //if ((TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) || drpT.Items.FindByValue(o.ToString()) != null)
                //{
                //    drpT.SelectedValue = o.ToString();
                //    return;
                //}
                // drpT.Items.Add(new ListItem(o.ToString(), o.ToString()));
                // drpT.SelectedValue = o.ToString();
                //魏军为了修改下拉框的enable属性而改。

                if ((!TaskAPI.IsBeginStep && TaskAPI.Step != "CA Check") || !TaskAPI.IsAllowSubmit)
                {
                    drpT.SelectedValue = o.ToString();
                    string item = drpT.SelectedItem.Text;
                    drpT.Items.Clear();
                    drpT.Items.Add(new ListItem(item, o.ToString()));
                    drpT.SelectedValue = o.ToString();
                }
                else
                {
                    if (drpT.Items.FindByValue(o.ToString().Trim()) != null)
                    {
                        drpT.SelectedValue = o.ToString();
                        return;
                    }
                    else
                    {
                        string item = drpT.SelectedItem.Text;
                        drpT.Items.Add(new ListItem(item, o.ToString()));
                        drpT.SelectedValue = o.ToString();
                    }
                }

            }
            catch (Exception)
            {
            }
        }
        #endregion

        #region 方法 抓取申请人Email
        private List<string> GetEmailByWinId(List<string> winIds)
        {
            if (winIds == null || winIds.Count <= 0) return null;
            const string sql = @"SELECT EMAIL FROM CLIENTS WHERE USERNAME IN ({0})";
            var ds = Storage.Context2.ExecuteDataSet(new Command(string.Format(sql, string.Join(",", winIds.ToArray()))));
            if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return null;
            var ret = new List<string>();
            foreach (System.Data.DataRow r in ds.Tables[0].Rows)
            {
                var email = r[0];
                if (email == null || email == DBNull.Value || ret.Contains(email as string)) continue;
                ret.Add(email as string);
            }
            return ret;
        }
        #endregion

        #region DMO获取SA Nname
        protected void SA_Name_TextChanged(object sender, EventArgs e)
        {
            DMO_Employee_Name.Text = SA_Name.Text;
        }
        #endregion

        #region DMO获取 SA ID
        protected void SA_ID_No_TextChanged(object sender, EventArgs e)
        {
            DMO_ID_Card.Text = SA_ID_No.Text;
        }
        #endregion

        #region DMO 获取Description
        protected void Description_TextChanged(object sender, EventArgs e)
        {
            if (VD_Description_2.Text == "")
            {
                DMO_Employee_Name.Text = VD_Description_1.Text;
            }
            else if (VD_Description_1.Text == "")
            {
                DMO_Employee_Name.Text = VD_Description_2.Text;
            }
            else if (VD_Description_1.Text != "" & VD_Description_2.Text != "")
            {
                DMO_Employee_Name.Text = VD_Description_2.Text;
            }
        }
        #endregion

        #region
        protected void SA_Vendor_Master_Code_TextChanged(object sender, EventArgs e)
        {
            if (VD_Category.SelectedValue == "2" & SA.Checked)
            {
                SAP_Code.Text = SA_Vendor_Master_Code.Text;
            }
        }
        protected void VD_Vendor_Master_Code_TextChanged(object sender, EventArgs e)
        {
            if (VD_Category.SelectedValue == "2" & VD.Checked)
            {
                SAP_Code.Text = VD_Vendor_Master_Code.Text;
            }
        }
        #endregion

        protected void SA_Temp_Staff_CheckedChanged(object sender, EventArgs e)
        {
            //P_Concur.Visible = !SA_Temp_Staff.Checked;
        }

        protected void SA_CTE_Login_Name_TextChanged(object sender, EventArgs e)
        {
            SA_Email_Address.Text = SA_CTE_Login_Name.Text;
        }

        protected void SA_Employee_ID_TextChanged(object sender, EventArgs e)
        {
            SA_Local_Personnel_Number.Text = SA_Employee_ID.Text;
        }





    }
}